# Maintainer: Cowington Post <cowingtonpost@gmail.com>
pkgname=logisim-evolution
pkgver=3.8.0
pkgrel=0
pkgdesc="Digital logic design tool and simulator"
url="https://github.com/logisim-evolution/logisim-evolution"
arch="x86_64 aarch64 s390x" # limited by java
license="GPL-3.0-or-later"
depends="openjdk17-jre hicolor-icon-theme"
makedepends="openjdk17-jdk"
source="https://github.com/logisim-evolution/logisim-evolution/archive/v$pkgver/logisim-evolution-$pkgver.tar.gz
logisim-evolution
Desktop-file.patch"
options="net !check"

build() {
	export GRADLE_USER_HOME="$srcdir"/.gradle
	./gradlew --parallel shadowJar
}

package() {
	install -Dm644 build/libs/logisim-evolution-"$pkgver"-all.jar \
		"$pkgdir"/usr/share/logisim-evolution/logisim-evolution.jar

	install -Dm644 support/Flatpak/com.github.reds.LogisimEvolution.xml \
		"$pkgdir"/usr/share/mime/packages/logisim-evolution.xml

	install -Dm644 support/Flatpak/com.github.reds.LogisimEvolution.desktop \
		"$pkgdir"/usr/share/applications/logisim-evolution.desktop

	install -Dm755 "$srcdir"/logisim-evolution "$pkgdir"/usr/bin/logisim-evolution

	local size
	for size in 16 32 48 128 256; do
		install -Dm644 \
			src/main/resources/resources/logisim/img/logisim-icon-"$size".png \
			"$pkgdir"/usr/share/icons/hicolor/"$size"x"$size"/apps/logisim-evolution.png
	done
}

sha512sums="
3f1b78fbd3cfe06c0d8fbe224481bd4134bc8583bdfd7b3009386281ede32526a847c23d02f1709707682a276dd8106cd49c120f774fb00c5d72ba3ccbb46f21  logisim-evolution-3.8.0.tar.gz
dc93426421ace75f6479fbfb49a5d54ba7c7b64a49be3d5336451639f26a559d9b3f1a93136863d921760d53646e6fbca7be1c3a6580b8132245c4980115e5ca  logisim-evolution
34a4331673bffd6db0f1a1c17a4879c5a4b48dc099b9bae9fb5b190a3541fe1e6c8d6a7bdf3f9d00691e3e002051bc509282d89a95847ff1f90f755986a797a3  Desktop-file.patch
"
